<?php

/*
  Project     : 48c6c450f1a4a0cc53d9585dc0fee742
  Created on  : Mar 16, 2013, 11:29:15 PM
  Author      : Truong Khuong - khuongxuantruong@gmail.com
  Description :
  Purpose of the stylesheet follows.
 */

class frontend_module extends CI_Module {

    function __construct() {
        parent::__construct();
    }
	
	function getAlbumByCode($code=''){
		$query = $this->db
                ->where('album_code',$code)
                ->where('album_status','true')
                ->get('tc_album');
        return $query->row();
	}
	
    function getAlbumByType($type=''){
        $query = $this->db
                ->where('album_type',$type)
                ->where('album_status','true')
                ->order_by('album_position','ASC')
                ->order_by('album_insert','DESC')
                ->get('tc_album');
        return $query->result();
    }

	function getImageByCode($code=''){
		$query = $this->db
                ->where('image_album_id',$code)
                ->where('image_status','true')
                ->order_by('image_position','ASC')
                ->order_by('image_insert','DESC')
                ->get('tc_image');
        return $query->result();
	}
	
    function get_configs() {
        $query = $this->db
                ->get('system');
        return $query->result();
    }
    function getBlockByType(){
        $query = $this->db
                ->where('block_type','HomeBlock')
                //->where('block_status','true')
                ->order_by('block_position','ASC')
                ->order_by('block_insert','DESC')
                ->get('tc_block');
        return $query->result();
    }
    function getProductType(){
        $query = $this->db
                ->where('type_type','Product')
                ->where('type_status','true')
                ->order_by('type_position','ASC')
                ->order_by('type_insert','DESC')
                ->get('tc_type');
        return $query->result();
    }
    function getDataSlider(){
        $query = $this->db
                ->where('data_type','Slider')
                ->where('data_status','true')
                ->order_by('data_position','ASC')
                ->order_by('data_insert','DESC')
                ->get('tc_data');
        return $query->result();
    }
	function getContent($Id=1){
        $query = $this->db
                ->where('content_id',$Id)
                ->get('tc_content');
        return $query->row();
    }
	function onInsertContact($params) {
        $this->db->set('contact_insert', 'NOW()', FALSE);
        $this->db->insert('tc_contactus', $params);
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if ($count == 1)
            return true;
        return false;
    }
	function getSetMenuByType($type=''){
		$query = $this->db
                ->where('setmenu_type',$type)
                ->where('setmenu_status','true')
                ->order_by('setmenu_position','ASC')
                ->order_by('setmenu_insert','DESC')
                ->get('tc_setmenu');
        return $query->result();
	}
    function getEventByType($type=''){
        $query = $this->db
                ->where('_type',$type)
                ->where('_status','true')
                ->order_by('_position','ASC')
                ->order_by('_insert','DESC')
                ->get('tc_event');
        return $query->result();
    }
}

?>
